package com.bwie.handler;

import com.bwie.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * @description:  项目全局异常捕获类
 * @author: xushuaihang
 * @Date: 2024/6/17 9:15
 * @param:
 * @param
 * @return:
**/
@ControllerAdvice
@Slf4j
public class GlobalExceptionClass {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public R error(Exception ex){
        ex.printStackTrace();

        log.error(ex.getMessage());

        return R.error().message("全局异常触发");
    }
}
